<template>
  <div class="customInput">
    <input type="text" :placeholder="placeholder" :value="modelValue" @input="inputType" :maxlength="max">
  </div>
</template>
<script>
import { defineComponent } from 'vue';
export default defineComponent({
  props: {
    modelValue: {
      default: () => '',
      type: String
    },
    placeholder: {
      type: String,
      default: () => ''
    },
    max: {
      type: Number,
      default: () => 0
    },
    textType: {
      default: () => 'text',
      type: String
    }
  },
  setup (props, { emit }) {
    const inputType = (event) => {
      let value = event.target.value
      if (props?.textType === 'number') value = value.replace(/[^\d]/g, '')
      emit('update:modelValue', value)
    }
    return {
      inputType
    }
  }
})
</script>

<style scoped lang="less">
.customInput {
  display: flex;
  width: 300px;
  height: 48px;
  background: #F4F4F4;
  border-radius: 6px;
  overflow: hidden;

  >input {
    border: none;
    outline: none;
    background: #F4F4F4;
    font-size: 16px;

    font-weight: 500;
    color: #242424;
    padding: 0 12px;
    width: 100%;
  }
}
</style>
